load('../../src/ph/ph.js');

SETTINGS = 'settings.js';
ph.bootstrap(SETTINGS);
ph.keepRunning();

dojo.require('jetty.Server');
dojo.require('games.Memory');
dojo.require('ph.rfid.PhidgetReader');

game = new games.Memory(FLICKR_API, TAGS, ph.rfid.PhidgetReader);
game.start();

server = new jetty.Server(8080, jettyResources);

var settings = readFile(SETTINGS).replace(DOJO_PATH, jettyResources[DOJO_PATH]);
server.register('/memory/settings.js', function(request, response) {
  response.type = 'text/javascript';
  response.body = settings;
});

server.register(POLL_FILE, function(request, response) {
  response.type = 'text/javascript';
  response.body = request.arguments['callback'] + '(' + dojo.toJson(game.data) + ')';
});

server.start();
